package com.bocai.freeman.view.activitys;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bocai.freeman.R;
import com.bocai.freeman.base.BaseActivity;
import com.bocai.freeman.utils.ToolbarHelper;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by admin on 2016/5/25.
 */
public class EditGenderActivity extends BaseActivity {

    @Bind(R.id.iv_man)
    ImageView mIvMan;
    @Bind(R.id.rl_man)
    RelativeLayout mRlMan;
    @Bind(R.id.iv_woman)
    ImageView mIvWoman;
    @Bind(R.id.rl_women)
    RelativeLayout mRlWomen;
    @Bind(R.id.toolbar)
    Toolbar mToolbar;

    private int position = 0;//用来标记选择的性别 默认是0(男)

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_modify_gender);
        ButterKnife.bind(this);
        initEvent();
    }

    @Override
    protected void initEvent() {
        super.initEvent();
        ToolbarHelper.setup(this, R.string.gender, R.mipmap.left_return);
        mToolbar.setOnMenuItemClickListener(item -> {
            // TODO: 2016/5/20 save modify infomation
            return true;
        });

        mRlMan.setOnClickListener(v -> {
            if(position == 0){

            }else {
                mIvMan.setVisibility(View.VISIBLE);
                mIvWoman.setVisibility(View.INVISIBLE);
            }
            position = 0;

        });

        mRlWomen.setOnClickListener(v -> {
            if(position !=1){
                mIvWoman.setVisibility(View.VISIBLE);
                mIvMan.setVisibility(View.INVISIBLE);
            }
            position =1;
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_save,menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }
}
